package com.margo.project.consumer.kafka.client.configure;

import java.util.Properties;

import org.apache.kafka.clients.admin.AdminClient;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MargoKafkaConfiguration {

	@Bean
	public AdminClient adminClient() {
		//AdminClientConfig adminClientConfig;
		Properties properties = new Properties();
		properties.put("bootstrap.servers", "localhost:9092");
		properties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
		properties.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
		AdminClient adminClient = AdminClient.create(properties);
		return adminClient;

	}
	
	@Bean
	public KafkaProducer<String, String> kafkaProducer() {
		Properties properties = new Properties();
		properties.put("bootstrap.servers", "localhost:9092");
		properties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
		properties.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
		KafkaProducer<String, String> kafkaProducer=new KafkaProducer<String, String>(properties);
		return kafkaProducer;

	}
	
	@Bean
	public KafkaConsumer<String, String> kafkaConsumer() {
		Properties properties = new Properties();
		properties.put("bootstrap.servers", "localhost:9092");
		properties.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
		properties.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
		KafkaConsumer<String, String> kafkaConsumer=new KafkaConsumer<String, String>(properties);
		return kafkaConsumer;

	}
}
